class copy
{
    public static int count=0;
    public synchronized void add()
    {
        count++;
    }
}


public class thread {
    public static copy a=new copy();

    public static void main(String[] args) {


        Thread thread1=new Thread(new Runnable() {
            @Override
            public void run() {
                long i=0;
                for(i=0;i<50000L;i++)
                {
                    a.add();
                }

            }
        });
        Thread thread2=new Thread(new Runnable() {
            @Override
            public void run() {
                long i=0;
                for(i=0;i<50000L;i++)
                {
                    a.add();
                }

            }
        });
        thread1.start();
        thread2.start();
        try {
            thread1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try {
            thread2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(a.count);

    }
}
